let s = "aacc", t = "ccac"

function isAnagram(s, t){
    if(s.length != t.length){
        return false
    }

    const charCount = {}
    
    for(let i = 0; i < s.length; i++){
        const char = s[i]
        if(charCount[char]){
            charCount[char]++
        }else{
            charCount[char] = 1
        }
    }
    
    for (let i = 0; i < t.length; i++){
        const char = t[i]
        if(!charCount[char]){
            return false
        }else{
            charCount[char]--
        }
    }

    return true
}

console.log(isAnagram(s, t))